import 'package:finance_app/src/entities/grant_entity.dart';

grantEntityFromJson(GrantEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['country'] != null) {
		data.country = json['country'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['agency'] != null) {
		data.agency = json['agency'].toString();
	}
	if (json['is_taxable'] != null) {
		data.isTaxable = json['is_taxable'] is String
				? int.tryParse(json['is_taxable'])
				: json['is_taxable'].toInt();
	}
	if (json['created_at'] != null) {
		data.createdAt = json['created_at'].toString();
	}
	if (json['updated_at'] != null) {
		data.updatedAt = json['updated_at'].toString();
	}
	return data;
}

Map<String, dynamic> grantEntityToJson(GrantEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['country'] = entity.country;
	data['name'] = entity.name;
	data['agency'] = entity.agency;
	data['is_taxable'] = entity.isTaxable;
	data['created_at'] = entity.createdAt;
	data['updated_at'] = entity.updatedAt;
	return data;
}